<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">

<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>gamvas.Sound</title><link rel="stylesheet" type="text/css" href="../styles/main.css"><script language=JavaScript src="../javascript/main.js"></script><script language=JavaScript src="../javascript/prettify.js"></script><script language=JavaScript src="../javascript/searchdata.js"></script></head><body class="ContentPage" onLoad="NDOnLoad();prettyPrint();"><script language=JavaScript><!--
if (browserType) {document.write("<div class=" + browserType + ">");if (browserVer) {document.write("<div class=" + browserVer + ">"); }}// --></script>

<!--  Generated by Natural Docs, version 1.51 -->
<!--  http://www.naturaldocs.org  -->

<!-- saved from url=(0026)http://www.naturaldocs.org -->




<div id=Content><div class="CClass"><div class=CTopic id=MainTopic><h1 class=CTitle><a name="gamvas.Sound"></a>gamvas.<wbr>Sound</h1><div class=CBody><h4 class=CHeading>Description</h4><p>A class for sound and music files.</p><h4 class=CHeading>Constructur</h4><p>new gamvas.Actor(file);</p><h4 class=CHeading>Parameters</h4><table border=0 cellspacing=0 cellpadding=0 class=CDescriptionList><tr><td class=CDLEntry>file</td><td class=CDLDescription>a JavaScript Audio class</td></tr></table><h4 class=CHeading>See</h4><p><a href="gamvas-state-state-js.html#gamvas.State.addSound" class=LFunction id=link10 onMouseOver="ShowTip(event, 'tt10', 'link10')" onMouseOut="HideTip('tt10')">gamvas.State.addSound</a></p><h4 class=CHeading>Example</h4><blockquote><pre>myState = gamvas.State.extend({
    init: function() {
        this.sound = this.addSound(&quot;introsound.wav&quot;);
    },
    onKeyDown: function() {
        this.sound.play();
    }
});</pre></blockquote><!--START_ND_SUMMARY--><div class=Summary><div class=STitle>Summary</div><div class=SBorder><table border=0 cellspacing=0 cellpadding=0 class=STable><tr class="SMain"><td class=SEntry><a href="#gamvas.Sound" >gamvas.<wbr>Sound</a></td><td class=SDescription>A class for sound and music files.</td></tr><tr class="SGroup SIndent1"><td class=SEntry><a href="#gamvas.Sound.Functions" >Functions</a></td><td class=SDescription></td></tr><tr class="SFunction SIndent2 SMarked"><td class=SEntry><a href="#gamvas.Sound.play" id=link1 onMouseOver="ShowTip(event, 'tt1', 'link1')" onMouseOut="HideTip('tt1')">play</a></td><td class=SDescription>Play the sound once, restarts the sound automatically</td></tr><tr class="SFunction SIndent2"><td class=SEntry><a href="#gamvas.Sound.loop" id=link2 onMouseOver="ShowTip(event, 'tt2', 'link2')" onMouseOut="HideTip('tt2')">loop</a></td><td class=SDescription>Play the sound looping (e.g. </td></tr><tr class="SFunction SIndent2 SMarked"><td class=SEntry><a href="#gamvas.Sound.stop" id=link3 onMouseOver="ShowTip(event, 'tt3', 'link3')" onMouseOut="HideTip('tt3')">stop</a></td><td class=SDescription>Stops a playing sound</td></tr><tr class="SFunction SIndent2"><td class=SEntry><a href="#gamvas.Sound.resume" id=link4 onMouseOver="ShowTip(event, 'tt4', 'link4')" onMouseOut="HideTip('tt4')">resume</a></td><td class=SDescription>Resumes a stopped sound, without rewinding it</td></tr><tr class="SFunction SIndent2 SMarked"><td class=SEntry><a href="#gamvas.Sound.setRate" id=link5 onMouseOver="ShowTip(event, 'tt5', 'link5')" onMouseOut="HideTip('tt5')">setRate</a></td><td class=SDescription>Set the playback speed of the sound</td></tr><tr class="SFunction SIndent2"><td class=SEntry><a href="#gamvas.Sound.setVolume" id=link6 onMouseOver="ShowTip(event, 'tt6', 'link6')" onMouseOut="HideTip('tt6')">setVolume</a></td><td class=SDescription>Set the volume of the sound</td></tr><tr class="SFunction SIndent2 SMarked"><td class=SEntry><a href="#gamvas.Sound.mute" id=link7 onMouseOver="ShowTip(event, 'tt7', 'link7')" onMouseOut="HideTip('tt7')">mute</a></td><td class=SDescription>Mute the sound</td></tr><tr class="SFunction SIndent2"><td class=SEntry><a href="#gamvas.Sound.unmute" id=link8 onMouseOver="ShowTip(event, 'tt8', 'link8')" onMouseOut="HideTip('tt8')">unmute</a></td><td class=SDescription>Unmute the sound</td></tr><tr class="SFunction SIndent2 SMarked"><td class=SEntry><a href="#gamvas.Sound.isReady" id=link9 onMouseOver="ShowTip(event, 'tt9', 'link9')" onMouseOut="HideTip('tt9')">isReady</a></td><td class=SDescription>Test if the sound is ready to play</td></tr></table></div></div><!--END_ND_SUMMARY--></div></div></div>

<div class="CGroup"><div class=CTopic><h3 class=CTitle><a name="gamvas.Sound.Functions"></a>Functions</h3></div></div>

<div class="CFunction"><div class=CTopic><h3 class=CTitle><a name="gamvas.Sound.play"></a>play</h3><div class=CBody><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td class="prettyprint">gamvas.Sound.prototype.play = function()</td></tr></table></blockquote><h4 class=CHeading>Description</h4><p>Play the sound once, restarts the sound automatically</p><h4 class=CHeading>See</h4><p><a href="#gamvas.Sound.stop" class=LFunction id=link11 onMouseOver="ShowTip(event, 'tt3', 'link11')" onMouseOut="HideTip('tt3')">gamvas.Sound.stop</a> <a href="#gamvas.Sound.resume" class=LFunction id=link12 onMouseOver="ShowTip(event, 'tt4', 'link12')" onMouseOut="HideTip('tt4')">gamvas.Sound.resume</a></p></div></div></div>

<div class="CFunction"><div class=CTopic><h3 class=CTitle><a name="gamvas.Sound.loop"></a>loop</h3><div class=CBody><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td class="prettyprint">gamvas.Sound.prototype.loop = function()</td></tr></table></blockquote><h4 class=CHeading>Description</h4><p>Play the sound looping (e.g. for background music)</p><h4 class=CHeading>See</h4><p><a href="#gamvas.Sound.stop" class=LFunction id=link13 onMouseOver="ShowTip(event, 'tt3', 'link13')" onMouseOut="HideTip('tt3')">gamvas.Sound.stop</a></p></div></div></div>

<div class="CFunction"><div class=CTopic><h3 class=CTitle><a name="gamvas.Sound.stop"></a>stop</h3><div class=CBody><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td class="prettyprint">gamvas.Sound.prototype.stop = function()</td></tr></table></blockquote><h4 class=CHeading>Description</h4><p>Stops a playing sound</p><h4 class=CHeading>See</h4><p><a href="#gamvas.Sound.resume" class=LFunction id=link14 onMouseOver="ShowTip(event, 'tt4', 'link14')" onMouseOut="HideTip('tt4')">gamvas.Sound.resume</a></p></div></div></div>

<div class="CFunction"><div class=CTopic><h3 class=CTitle><a name="gamvas.Sound.resume"></a>resume</h3><div class=CBody><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td class="prettyprint">gamvas.Sound.prototype.resume = function()</td></tr></table></blockquote><h4 class=CHeading>Description</h4><p>Resumes a stopped sound, without rewinding it</p><h4 class=CHeading>See</h4><p><a href="#gamvas.Sound.stop" class=LFunction id=link15 onMouseOver="ShowTip(event, 'tt3', 'link15')" onMouseOut="HideTip('tt3')">gamvas.Sound.stop</a> <a href="#gamvas.Sound.play" class=LFunction id=link16 onMouseOver="ShowTip(event, 'tt1', 'link16')" onMouseOut="HideTip('tt1')">gamvas.Sound.play</a></p></div></div></div>

<div class="CFunction"><div class=CTopic><h3 class=CTitle><a name="gamvas.Sound.setRate"></a>setRate</h3><div class=CBody><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class="PBeforeParameters  prettyprint "nowrap>gamvas.Sound.prototype.setRate = function(</td><td class="PParameter  prettyprint " nowrap>r</td><td class="PAfterParameters  prettyprint "nowrap>)</td></tr></table></td></tr></table></blockquote><h4 class=CHeading>Description</h4><p>Set the playback speed of the sound</p><h4 class=CHeading>Parameters</h4><table border=0 cellspacing=0 cellpadding=0 class=CDescriptionList><tr><td class=CDLEntry>r</td><td class=CDLDescription>the new speed (1 = normal, &lt; 1 = faster, &gt; 2 = slower)</td></tr></table><h4 class=CHeading>Note</h4><p>Playback quality on none standard speeds differs drastically between browsers</p></div></div></div>

<div class="CFunction"><div class=CTopic><h3 class=CTitle><a name="gamvas.Sound.setVolume"></a>setVolume</h3><div class=CBody><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class="PBeforeParameters  prettyprint "nowrap>gamvas.Sound.prototype.setVolume = function(</td><td class="PParameter  prettyprint " nowrap>v</td><td class="PAfterParameters  prettyprint "nowrap>)</td></tr></table></td></tr></table></blockquote><h4 class=CHeading>Description</h4><p>Set the volume of the sound</p><h4 class=CHeading>Parameters</h4><table border=0 cellspacing=0 cellpadding=0 class=CDescriptionList><tr><td class=CDLEntry>v</td><td class=CDLDescription>the new volume between 0 and 1</td></tr></table></div></div></div>

<div class="CFunction"><div class=CTopic><h3 class=CTitle><a name="gamvas.Sound.mute"></a>mute</h3><div class=CBody><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td class="prettyprint">gamvas.Sound.prototype.mute = function()</td></tr></table></blockquote><h4 class=CHeading>Description</h4><p>Mute the sound</p></div></div></div>

<div class="CFunction"><div class=CTopic><h3 class=CTitle><a name="gamvas.Sound.unmute"></a>unmute</h3><div class=CBody><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td class="prettyprint">gamvas.Sound.prototype.unmute = function()</td></tr></table></blockquote><h4 class=CHeading>Description</h4><p>Unmute the sound</p></div></div></div>

<div class="CFunction"><div class=CTopic><h3 class=CTitle><a name="gamvas.Sound.isReady"></a>isReady</h3><div class=CBody><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td class="prettyprint">gamvas.Sound.prototype.isReady = function()</td></tr></table></blockquote><h4 class=CHeading>Description</h4><p>Test if the sound is ready to play</p><h4 class=CHeading>Returns</h4><p>true/false</p></div></div></div>

</div><!--Content-->


<div id=Footer><a href="http://www.naturaldocs.org">Generated by Natural Docs</a></div><!--Footer-->


<div id=Menu><div class=MEntry><div class=MFile><a href="gamvas-base-js.html">gamvas</a></div></div><div class=MEntry><div class=MFile><a href="gamvas-actor-js.html">gamvas.<wbr>Actor</a></div></div><div class=MEntry><div class=MFile><a href="gamvas-actorstate-js.html">gamvas.<wbr>ActorState</a></div></div><div class=MEntry><div class=MFile><a href="gamvas-animation-js.html">gamvas.<wbr>Animation</a></div></div><div class=MEntry><div class=MFile><a href="gamvas-camera-js.html">gamvas.<wbr>Camera</a></div></div><div class=MEntry><div class=MFile><a href="gamvas-class-js.html">gamvas.<wbr>Class</a></div></div><div class=MEntry><div class=MFile><a href="gamvas-dom-js.html">gamvas.dom</a></div></div><div class=MEntry><div class=MFile><a href="gamvas-event-js.html">gamvas.<wbr>event</a></div></div><div class=MEntry><div class=MFile><a href="gamvas-image-js.html">gamvas.<wbr>Image</a></div></div><div class=MEntry><div class=MFile><a href="gamvas-key-js.html">gamvas.key</a></div></div><div class=MEntry><div class=MFile><a href="gamvas-mouse-js.html">gamvas.<wbr>mouse</a></div></div><div class=MEntry><div class=MFile><a href="gamvas-particleemitter-js.html">gamvas.<wbr>ParticleEmitter</a></div></div><div class=MEntry><div class=MFile><a href="gamvas-physics-js.html">gamvas.<wbr>physics</a></div></div><div class=MEntry><div class=MFile><a href="gamvas-physics-userdata-js.html">gamvas.<wbr>physics.<wbr>UserData</a></div></div><div class=MEntry><div class=MFile><a href="gamvas-rect-js.html">gamvas.Rect</a></div></div><div class=MEntry><div class=MFile><a href="gamvas-resource-js.html">gamvas.<wbr>Resource</a></div></div><div class=MEntry><div class=MFile><a href="gamvas-screen-js.html">gamvas.<wbr>screen</a></div></div><div class=MEntry><div class=MFile id=MSelected>gamvas.<wbr>Sound</div></div><div class=MEntry><div class=MFile><a href="gamvas-state-js.html">gamvas.<wbr>state</a></div></div><div class=MEntry><div class=MFile><a href="gamvas-state-state-js.html">gamvas.<wbr>State</a></div></div><div class=MEntry><div class=MFile><a href="gamvas-timer-js.html">gamvas.<wbr>timer</a></div></div><div class=MEntry><div class=MFile><a href="gamvas-vector2d-js.html">gamvas.<wbr>Vector2D</a></div></div><div class=MEntry><div class=MGroup><a href="javascript:ToggleMenu('MGroupContent1')">Index</a><div class=MGroupContent id=MGroupContent1><div class=MEntry><div class=MIndex><a href="../index/General.html">Everything</a></div></div><div class=MEntry><div class=MIndex><a href="../index/Classes.html">Classes</a></div></div><div class=MEntry><div class=MIndex><a href="../index/Functions.html">Functions</a></div></div><div class=MEntry><div class=MIndex><a href="../index/Macros.html">Macros</a></div></div><div class=MEntry><div class=MIndex><a href="../index/Variables.html">Variables</a></div></div></div></div></div><script type="text/javascript"><!--
var searchPanel = new SearchPanel("searchPanel", "HTML", "../search");
--></script><div id=MSearchPanel class=MSearchPanelInactive><input type=text id=MSearchField value=Search onFocus="searchPanel.OnSearchFieldFocus(true)" onBlur="searchPanel.OnSearchFieldFocus(false)" onKeyUp="searchPanel.OnSearchFieldChange()"><select id=MSearchType onFocus="searchPanel.OnSearchTypeFocus(true)" onBlur="searchPanel.OnSearchTypeFocus(false)" onChange="searchPanel.OnSearchTypeChange()"><option  id=MSearchEverything selected value="General">Everything</option><option value="Classes">Classes</option><option value="Functions">Functions</option><option value="Macros">Macros</option><option value="Variables">Variables</option></select></div></div><!--Menu-->



<!--START_ND_TOOLTIPS-->
<div class=CToolTip id="tt1"><div class=CFunction><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td class="prettyprint">gamvas.Sound.prototype.play = function()</td></tr></table></blockquote>Play the sound once, restarts the sound automatically</div></div><div class=CToolTip id="tt2"><div class=CFunction><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td class="prettyprint">gamvas.Sound.prototype.loop = function()</td></tr></table></blockquote>Play the sound looping (e.g. </div></div><div class=CToolTip id="tt3"><div class=CFunction><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td class="prettyprint">gamvas.Sound.prototype.stop = function()</td></tr></table></blockquote>Stops a playing sound</div></div><div class=CToolTip id="tt4"><div class=CFunction><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td class="prettyprint">gamvas.Sound.prototype.resume = function()</td></tr></table></blockquote>Resumes a stopped sound, without rewinding it</div></div><div class=CToolTip id="tt5"><div class=CFunction><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class="PBeforeParameters  prettyprint "nowrap>gamvas.Sound.prototype.setRate = function(</td><td class="PParameter  prettyprint " nowrap>r</td><td class="PAfterParameters  prettyprint "nowrap>)</td></tr></table></td></tr></table></blockquote>Set the playback speed of the sound</div></div><div class=CToolTip id="tt6"><div class=CFunction><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class="PBeforeParameters  prettyprint "nowrap>gamvas.Sound.prototype.setVolume = function(</td><td class="PParameter  prettyprint " nowrap>v</td><td class="PAfterParameters  prettyprint "nowrap>)</td></tr></table></td></tr></table></blockquote>Set the volume of the sound</div></div><div class=CToolTip id="tt7"><div class=CFunction><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td class="prettyprint">gamvas.Sound.prototype.mute = function()</td></tr></table></blockquote>Mute the sound</div></div><div class=CToolTip id="tt8"><div class=CFunction><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td class="prettyprint">gamvas.Sound.prototype.unmute = function()</td></tr></table></blockquote>Unmute the sound</div></div><div class=CToolTip id="tt9"><div class=CFunction><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td class="prettyprint">gamvas.Sound.prototype.isReady = function()</td></tr></table></blockquote>Test if the sound is ready to play</div></div><div class=CToolTip id="tt10"><div class=CFunction><blockquote><table border=0 cellspacing=0 cellpadding=0 class="Prototype"><tr><td><table border=0 cellspacing=0 cellpadding=0><tr><td class="PBeforeParameters  prettyprint "nowrap>addSound: function(</td><td class="PParameter  prettyprint " nowrap>snd</td><td class="PAfterParameters  prettyprint "nowrap>)</td></tr></table></td></tr></table></blockquote>Add a gamvas.Sound to the state.</div></div><!--END_ND_TOOLTIPS-->




<div id=MSearchResultsWindow><iframe src="" frameborder=0 name=MSearchResults id=MSearchResults></iframe><a href="javascript:searchPanel.CloseResultsWindow()" id=MSearchResultsWindowClose>Close</a></div>


<script language=JavaScript><!--
if (browserType) {if (browserVer) {document.write("</div>"); }document.write("</div>");}// --></script></body></html>